/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.cmp.arena;

import com.cmp.arena.controls.CameraControl;
import com.jme3.math.Vector3f;
import com.jme3.renderer.Camera;
import com.jme3.scene.CameraNode;
import com.jme3.scene.Node;
import com.jme3.scene.control.CameraControl.ControlDirection;

/**
 *
 * @author pfanne
 */
public class CameraFactory {
    
    public static void makeCamera(Node node, Node target, Camera cam) {
        // Disable the default flyby cam
       
        //create the camera Node
        CameraNode camNode = new CameraNode("FollowCam", cam);
        //This mode means that camera copies the movements of the target:
        camNode.setControlDir(ControlDirection.SpatialToCamera);
        //Attach the camNode to the target:
        node.attachChild(camNode);
        //Move camNode, e.g. behind and above the target:
        camNode.setLocalTranslation(new Vector3f(0, 25, -25));
        //Rotate the camNode to look at the target:
        camNode.lookAt(node.getLocalTranslation(), Vector3f.UNIT_Y);
        node.addControl(new CameraControl(target));
    }
    
}
